package com.gang.controller;

import com.gang.pojo.CommonResult;
import com.gang.pojo.Datas;
import com.gang.pojo.TokenURI;
import com.gang.service.DataService;
import com.gang.utils.IPFSUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.Scanner;
import java.util.UUID;

@Controller
@RequestMapping("/data")
@Api(tags = "数据服务")
public class DataController{

    @Autowired
    DataService dataService;

    @RequestMapping("/nft/{pri}")
    @ResponseBody
    @ApiOperation("生成NFT")
    public CommonResult createNFT( @RequestParam("pri") String pri,@RequestBody TokenURI tokenURI){
        UUID uuid = dataService.setTokenURI(tokenURI);
        try {
            String upload = IPFSUtil.upload("H:\\" + uuid + ".json");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new CommonResult(200,"nft",1);
    }

}
